package com.example.shuiyin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.shuiyin.entity.UserQuota;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserQuotaMapper extends BaseMapper<UserQuota> {
    
    @Select("SELECT * FROM user_quota WHERE user_id = #{userId}")
    UserQuota selectByUserId(@Param("userId") Long userId);
    
    @Update("UPDATE user_quota SET used_storage_size = #{usedSize}, updated_at = NOW() WHERE user_id = #{userId}")
    int updateUsedStorageSize(@Param("userId") Long userId, @Param("usedSize") Long usedSize);
    
    @Update("UPDATE user_quota SET used_processing_count = used_processing_count + 1, updated_at = NOW() WHERE user_id = #{userId}")
    int incrementUsedProcessingCount(@Param("userId") Long userId);
    
    @Update("UPDATE user_quota SET used_processing_count = #{count}, updated_at = NOW() WHERE user_id = #{userId}")
    int updateUsedProcessingCount(@Param("userId") Long userId, @Param("count") Integer count);
} 